package com.tdk.bts.view;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;

import com.tdk.bts.entity.Film;
import com.tdk.bts.util.DateUtil;
import com.tdk.bts.util.ImageUtil;

public class FilmItemView extends JPanel{

	
	
	public FilmItemView(final Film film,final JFrame jf) {
		super();
		this.setLayout(null);
		
		JLabel imgLabel = new JLabel();
		String imgUrl = film.getPicUrl()!= null ? film.getPicUrl() : "default.jpg";
		imgLabel.setIcon(ImageUtil.getImage(imgUrl, 80, 120));
		imgLabel.setBounds(10, 10, 80, 120);
		this.add(imgLabel);
		
		JLabel titleLabel = new JLabel(film.getName());
		titleLabel.setBounds(100, 0, 200, 50);
		titleLabel.setFont(new Font("宋体", Font.BOLD, 20));
		this.add(titleLabel);
		
		
		JLabel infoLabel = new JLabel(film.getInfo());
		infoLabel.setBounds(100, 20, 200, 50);
		infoLabel.setFont(new Font("宋体", Font.PLAIN, 20));
		this.add(infoLabel);
		
		String dateStr = DateUtil.date2String(film.getPublishDate());
		JLabel dateLabel = new JLabel(dateStr);
		dateLabel.setBounds(100, 80, 200, 50);
		dateLabel.setFont(new Font("宋体", Font.PLAIN, 20));
		dateLabel.setForeground(new Color(51, 136, 255));
		this.add(dateLabel);
		
		JLabel book = new JLabel();
		book.setIcon(ImageUtil.getImage("book.png",70,40));
		book.setBounds(310, 20, 100, 50);
		book.setCursor(new Cursor(Cursor.HAND_CURSOR));
		this.add(book);
		this.setBorder(new MatteBorder(0, 0, 1, 0, new Color(0xC3C3C3)));
		
		
		book.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				//jf.dispose();
				new SeatChoiceView(film).show();
			};
		});
		
	}

	
	
	
	
}
